<template>
	<el-row class="FrontHeader">
		<el-row ref="header" class="FrontHeader-Header">
			<el-col v-if="!this.$objif(user)">
				<el-row type="flex" justify="end">
					<el-col style="color: #7795ff;" :span="2">
						<i class="el-icon-ship"></i>
						<span class="ToLogin" @click="ToLogin">登录</span>
					</el-col>
					<el-col @click="ToLogin" :span="3">
						<i style="color: #ff7c1e;" class="el-icon-s-goods"></i>
						<span class="ToLogin" @click="ToLogin">我的订单</span>
					</el-col>
				</el-row>
			</el-col>
			<el-col v-if="this.$objif(user)">
				<el-row type="flex" justify="end">
					<el-col :span="3">
						<i style="color: #7795ff;" class="el-icon-user-solid"></i>
						<span class="ToLogin" @click="ToCenterIndex">
							个人中心
						</span>
					</el-col>
					<el-col :span="3">
						<i style="color: #ff7c1e;" class="el-icon-s-goods"></i>
						<span class="ToLogin" @click="ToCenterIndex">
							我的订单
						</span>
					</el-col>
					<el-col :span="3">
						<i style="color: #ff4e3e;" class="el-icon-switch-button"></i>
						<span class="ToLogin" @click="exit">
							退出
						</span>
					</el-col>
				</el-row>
			</el-col>
		</el-row>
		<!-- <el-row v-if="inUser"  class="FrontHeader-Nav">
			<el-col>
				<el-row class="FrontHeader-Nav-Query" type="flex" style="height: 100%;">
					<el-col :span="14" :offset='4'>
						<el-autocomplete class="inline-input" v-model="state1" :fetch-suggestions="querySearch"
							placeholder="请输入您感兴趣的内容" @select="handleSelect">
						</el-autocomplete>
					</el-col>
					<el-button>查询</el-button>
				</el-row>
			</el-col>
			<el-col class="FrontHeader-Nav-left y_flex y_flex_al_cen">
				<div>123</div>
				<el-radio-group @change='GroupChange' v-model="nav_obj.name">
					<el-radio-button
					v-for="(item,index) in nav_obj.nav_list" 
					:key='index' 
					:label="item.title"></el-radio-button>
				</el-radio-group>
			</el-col>
		</el-row>
		<el-divider></el-divider> -->
	</el-row>
</template>

<script>
import { color } from 'echarts';
	export default {
		data() {
			return {
				restaurants: [],
				state1: '',
				inUser:false,
				
				nav_obj: {
					name: '',
					nav_list: [
						{
							title: '首页',
							puth: '/EntryPage/EntryPage'
						},
						{
							title: '列表',
							puth: '/ListItem/ListItem'
						},
					],
				},
				user: this.$store.getters.getUser,
			}
		},
		mounted() {
			this.restaurants = this.loadAll();
			this.GetRouteName()
			this.route_bg()
		},
		methods: {
			route_bg(){
				if(this.$route.name == '拍卖列表详情'){
					this.$refs.header.$el.style.background = '#d7dadd'
				}
			},
			exit(){
				this.$store.commit('relUser')
				this.user = this.$store.getters.getUser
				this.$router.push('/')
			},
			
			ToCenterIndex(){
				this.$router.push('/Center/Index')
			},
			
			ToLogin(){
				this.$router.push('/User/Login')
			},
			
			GetRouteName(){
				if(this.$route.path.indexOf('Center') != -1){
					this.inUser = false
				}else{
					this.inUser = true
				}
				if(this.$route.name.indexOf("列表") == -1){
					this.nav_obj.name = this.$route.name
				}else{
					this.nav_obj.name = "列表"
				}
				
			},
			
			GroupChange(res){
				var nav = this.nav_obj.nav_list
				for(let item=0;item<nav.length;item++){
					if (res == nav[item].title){
						this.$emit('toPuth',nav[item].puth)
						break
					}
				}
			},

			querySearch(queryString, cb) {
				var restaurants = this.restaurants;
				var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
				// 调用 callback 返回建议列表的数据
				cb(results);
			},
			createFilter(queryString) {
				return (restaurant) => {
					return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
				};
			},
			loadAll() {
				return [{
						"value": "三全鲜食（北新泾店）",
						"address": "长宁区新渔路144号"
					},
					{
						"value": "Hot honey 首尔炸鸡（仙霞路）",
						"address": "上海市长宁区淞虹路661号"
					},
					{
						"value": "新旺角茶餐厅",
						"address": "上海市普陀区真北路988号创邑金沙谷6号楼113"
					},
					{
						"value": "泷千家(天山西路店)",
						"address": "天山西路438号"
					},
					{
						"value": "胖仙女纸杯蛋糕（上海凌空店）",
						"address": "上海市长宁区金钟路968号1幢18号楼一层商铺18-101"
					},
				];
			},
			handleSelect(item) {
				console.log(item);
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'index.scss'
</style>
